package com.room2.ui;

import android.app.Application;

import com.room2.App;
import com.room2.model.Score;
import com.room2.model.ScoreDao;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

public class ScoreViewModel extends AndroidViewModel {
    private ScoreDao scoreDao;
    private LiveData<List<Score>> allData;

    public ScoreViewModel(@NonNull Application application) {
        super(application);
        scoreDao = App.APP_DATABASE.getScoreDao();
        allData = scoreDao.getAllData();
    }


    public LiveData<List<Score>> getAllData() {
        return allData;
    }

    public void insert(Score... scores){
        scoreDao.insert(scores);
    }

    public void update(Score... scores){
        scoreDao.update(scores);
    }

    public void delete(Score... scores){
        scoreDao.delete(scores);
    }

    public void clear(){
        scoreDao.clear();
    }
}
